package com.oocl.ha.entity;

import java.util.Set;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.OneToMany;
import javax.persistence.Table;

import com.fasterxml.jackson.annotation.JsonBackReference;
import com.fasterxml.jackson.annotation.JsonManagedReference;

@Entity
@Table(name = "tuser")
public class User {
	@Id
	@Column(name = "usid")
	@GeneratedValue(strategy = GenerationType.SEQUENCE)
	private Integer uid;

	@Column(name = "account")
	private String account;

	@Column(name = "password")
	private String password;
	
	@Column(name="address")
	private String address;
	@JsonBackReference
	@OneToMany(targetEntity = Order.class, mappedBy = "user", cascade = CascadeType.ALL, fetch = FetchType.LAZY)
	private Set<Order> orders;

	public User() {
		super();
	}
	public User(Integer uid, String account, String password, String address, Set<Order> orders) {
		super();
		this.uid = uid;
		this.account = account;
		this.password = password;
		this.address = address;
		this.orders = orders;
	}

	public Integer getUid() {
		return uid;
	}

	public void setUid(Integer uid) {
		this.uid = uid;
	}

	public String getAccount() {
		return account;
	}

	public void setAccount(String account) {
		this.account = account;
	}

	public String getPassword() {
		return password;
	}

	public void setPassword(String password) {
		this.password = password;
	}

	public Set<Order> getOrders() {
		return orders;
	}

	public void setOrders(Set<Order> orders) {
		this.orders = orders;
	}
	public String getAddress() {
		return address;
	}
	public void setAddress(String address) {
		this.address = address;
	}

}
